-- @owner: lihongji
-- @date: 2022/07/26
-- @testpoint: 使用函数创建系统视图

--step1:建序列;expect:成功
drop sequence if exists pop_samp_variance_seq_avgx;
create sequence pop_samp_variance_seq_avgx increment by 1 start with 10;

--step2:建表并插入数据;expect:成功
drop table if exists table_0001 cascade;
create table table_0001(
  col_1 integer,
  col_2 number(19,0),
  col_3 number(10,6)
) with (storage_type=ustore);
begin
 for i in 1..50 loop
  insert into table_0001 values(
  i,
  pop_samp_variance_seq_avgx.nextval,
  i+445.255
  );
 end loop;
end;
/

--step3:建视图;expect:成功
drop view if exists t_now_view;
create view t_now_view as select regr_avgx(col_1,col_2) from table_0001;

--step4:查询;expect:成功
select * from t_now_view;

--step5:清理环境;expect:成功
drop view if exists t_now_view;
drop sequence if exists pop_samp_variance_seq_avgx;
drop table if exists table_0001 cascade;